/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.account.Key.AccountBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.AccountServiceException;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import com.zimbra.cs.mailbox.MailboxManager;
/*    */ import com.zimbra.cs.mailbox.calendar.cache.CalendarCacheManager;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class PurgeAccountCalendarCache
/*    */   extends AdminDocumentHandler
/*    */ {
/* 41 */   private static final String[] TARGET_ACCOUNT_PATH = { "id" };
/* 42 */   protected String[] getProxiedAccountPath() { return TARGET_ACCOUNT_PATH; }
/*    */   
/*    */ 
/*    */ 
/*    */   public boolean domainAuthSufficient(Map<String, Object> context)
/*    */   {
/* 48 */     return true;
/*    */   }
/*    */   
/*    */   public Element handle(Element request, Map<String, Object> context) throws ServiceException {
/* 52 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/*    */     
/*    */ 
/* 55 */     checkRight(zsc, context, null, AdminRight.PR_SYSTEM_ADMIN_ONLY);
/*    */     
/* 57 */     Provisioning prov = Provisioning.getInstance();
/*    */     
/* 59 */     String id = request.getAttribute("id");
/* 60 */     Account account = prov.get(Key.AccountBy.id, id, zsc.getAuthToken());
/* 61 */     if (account == null) {
/* 62 */       throw AccountServiceException.NO_SUCH_ACCOUNT(id);
/*    */     }
/* 64 */     if (!Provisioning.onLocalServer(account)) {
/* 65 */       throw ServiceException.WRONG_HOST(account.getAttr("zimbraMailHost"), null);
/*    */     }
/* 67 */     CalendarCacheManager calCache = CalendarCacheManager.getInstance();
/* 68 */     ZimbraLog.calendar.info("Purging calendar cache for account " + account.getName());
/* 69 */     Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account, false);
/* 70 */     if (mbox != null)
/* 71 */       calCache.purgeMailbox(mbox);
/* 72 */     Element response = zsc.createElement(AdminConstants.PURGE_ACCOUNT_CALENDAR_CACHE_RESPONSE);
/* 73 */     return response;
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 78 */     notes.add("Only system admins are allowed.");
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/PurgeAccountCalendarCache.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */